using System;
using System.ComponentModel;
using System.ComponentModel.Design;

using System.Drawing;
using System.Drawing.Drawing2D;

namespace Camalon.Drawing
{

	/// <summary>
	/// Summary description for ShapePen.
	/// </summary>
	[ToolboxItem( true )]
	[ToolboxBitmap( typeof( ShapePen ), "Components.ShapePen.bmp")]
    [Editor("Camalon.Drawing.Design.ShapePenEditor, Camalon.Drawing.Design", typeof(System.Drawing.Design.UITypeEditor))]
    [Designer("Camalon.Drawing.Design.ShapePenDesigner, Camalon.Drawing.Design", typeof(IDesigner))]
    public class ShapePen:ShapePenBase//ContainerComponentBase	
	{
//		bool				_inset;//Reserved for future
		TransparentColor	_color;
		bool				_foregroundPen;
		ShapeFill			_fill; 


		#region Constructor
//		public ShapePen(System.ComponentModel.IContainer container):this()
//		{
//			///
//			/// Required for Windows.Forms Class Composition Designer support
//			///
//			container.Add(this);
//
//		}

		public ShapePen():base()
		{
			//DEFAULTS
			//-------------------------
			_color			= new TransparentColor( System.Drawing.Color.Black );
			_foregroundPen	= true;
			//--------------------------
		}


		public ShapePen(ShapeFill shapeFill):this(shapeFill, 1f){}


		public ShapePen(ShapeFill shapeFill, float width):base(width)
		{
			_fill = shapeFill;
			if( _fill != null) _fill.InternalChanged += new EventHandler(OnInternalChanged);
		}


		public ShapePen(TransparentColor color):this(color, 1f){}


		public ShapePen(TransparentColor color, float width):base(width)
		{
			_color = color;
		}


		#endregion Constructor

		#region Properties

//		[DefaultValue( false)]
//		[Description("Represents the alignment for this ShapePen object.")]
//		[RefreshProperties(RefreshProperties.Repaint)]
//		public bool Inset
//		{
//			get{ return _inset;} 
//			set
//			{ 
//				if( value == _inset ) return;
//				_inset = value;
//				InvokeInternalChanged();
//			}
//		}


		[Description("Color of this ShapePen object.")] 
		[DefaultValue(typeof( TransparentColor), "Black")]
		[RefreshProperties(RefreshProperties.Repaint)]
		public TransparentColor Color
		{
			get{ return _color;}
			set
			{
				if( _color.Equals(value)||_color.IsEmpty ) return;
				_color = value;
				InvokeInternalChanged();
			}
		}


		[DefaultValue(null)]
		[Description("A ShapeFill object that determines attributes of this ShapePen.It overrides the Color property of the ShapePen object.")] 
		[RefreshProperties(RefreshProperties.Repaint)]
		public ShapeFill Fill
		{
			get{ return _fill;} 
			set
			{ 
				
				if( value == _fill ) return;

				if( value != null && value.FillType == FillType.PathGradient)
					throw  new InvalidOperationException("ShapePen object cannot draw using a PathGradientFill object");

				if( _fill != null) _fill.InternalChanged -= new EventHandler(OnInternalChanged);
				_fill = value;
				if( _fill != null) _fill.InternalChanged += new EventHandler(OnInternalChanged);

				InvokeInternalChanged();
			}
		}

 
		[DefaultValue( true)]
		[Description("Indicates, whether the the Shape should be drawn with this ShapePen object before or after the shape fill.")]
		[RefreshProperties(RefreshProperties.Repaint)]
		public bool ForegroundPen
		{
			get{ return _foregroundPen;}
			set
			{
				if( value == _foregroundPen) return;
				_foregroundPen = value;
				InvokeInternalChanged();
			}
		}



		#endregion Properties

	}
}
